#include <iostream>
#include "AclProcess.h"
#include <sys/time.h>
#include "opencv2/opencv.hpp"

using namespace std;
using namespace cv;

int main(int argc,char** argv)
{
    struct timeval start;
    struct timeval end;

    if(argc <= 2){
        cout << "please run: ACL_YOLOV3 xxx.om xxx.jpg" <<endl;
        return -1;
    }

    Mat img = imread(argv[2]);
    if(img.empty()){
        cout << "read image faild." << endl;
        return -1;
    }
    
    AclProcess aclprocess;
    aclError ret = aclprocess.Init(0, "" ,argv[1]);
    if(ret != ACL_ERROR_NONE){
        cout << "AclProcess Init faild." << endl;
        return -1;
    }
    gettimeofday(&start,NULL);

    aclprocess.Process(img);

    gettimeofday(&end,NULL);
    cout<<"cost time : "<<(end.tv_sec-start.tv_sec)*1000+(end.tv_usec-start.tv_usec) / 1000.0 <<"ms"<<endl;

    imwrite("result.jpg",img);

    return 0;
}